/*
 *  msw7/appImp.cpp
 *  mini
 *
 *  Created by jin on 1/1/11.
 *  Copyright 2011 cs. All rights reserved.
 *
 */

#include "msw7/appImp.h"

#include <windows.h>
#include <msw7/graphic2d.h>

MSW7AppImp::MSW7AppImp(AppBase* owner_) : AppImpBase(owner_)
{
}

MSW7AppImp::~MSW7AppImp()
{
    CoUninitialize();
}

bool MSW7AppImp::OnInit()
{
    HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);

    if ( SUCCEEDED(CoInitialize(NULL)) )
    {
        return MSW7Graphic2D::Init();
    }

    return false;
}

void MSW7AppImp::Run()
{
    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0))
    {
        if (!TranslateAccelerator(msg.hwnd, NULL, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
}
